@echo off
setlocal

set "inputFilePath=%1"
set "destDirectory=%2"
set "fileName=%3"

rem Remove extension from file name
for %%f in ("%fileName%") do set "fileNameR=%%~nf"

set "m3u8FilePath=%destDirectory%\%fileNameR%.m3u8"
set "tsFilePattern=%destDirectory%\%fileNameR%_%%03d.ts"

rem Set duration to 60 seconds (1 minute)
set "duration=60"

ffmpeg -i "%inputFilePath%" ^
    -c:v libx264 ^
    -c:a aac ^
    -b:a 128k ^
    -b:v 400k ^
    -vf fps=25 ^
    -f hls ^
    -hls_time 10 ^
    -hls_list_size 0 ^
    -hls_segment_filename "%tsFilePattern%" ^
    -t %duration% ^
    "%m3u8FilePath%"

endlocal
